import request from '@/utils/request'

// api地址
const api = {
  list: '/store/pick-orders/page',
  count: '/store/pick-orders/count',
  complete: '/store/pick-orders/complete',
  up: '/store/pick-orders/hangup',
  preempt: '/store/pick-orders/preempt',
  start: '/store/pick-orders/start',
  tabPop: '/store/pick-orders/tab-pop',
  allocate: '/store/pick-orders/allocate',
  review: '/store/pick-orders/review',
  user: '/store/pick-users',
  userList: '/store/pick-users/list',
  detail: '/store/pick-orders/details'
}

// 分页查询当前拣货员拣货单列表
export const getPickList = (param, option) => {
  return request.get(api.list, param, option)
}

// 当前拣货员已完成拣货单汇总
export const getPickCount = (param, option) => {
  return request.get(api.count, param, option)
}

// 完成拣货
export const complete = (param, option) => {
  return request.post(api.complete, param, option)
}

// 挂起拣货
export const handUp = (param, option) => {
  return request.post(api.up, param, option)
}

// 抢单
export const preempt = (param, option) => {
  return request.post(api.preempt, param, option)
}

// 开始拣货
export const start = (param, option) => {
  return request.post(api.start, param, option)
}

// 各个状态拣货单数量
export const getTabPop = (param) => {
  return request.get(api.tabPop, param, { load: false })
}

// 拣货单手动派单
export const allocate = (param, option) => {
  return request.post(api.allocate, param, option)
}

// 获取拣货单商品列表
export const detail = (param, option) => {
  return request.get(api.detail, param, option)
}

// 复核
export const review = (param, option) => {
  return request.post(api.review, param, option)
}

// 获取拣货用户状态
export const getPickUser = (param) => {
  return request.get(api.user, param, { load: false, isPrompt: false })
}

// 修改当前拣货员状态
export const setPickUser = (pickStatus) => {
  return request.put(`${api.user}/${pickStatus}`, {}, { load: false })
}

// 当前门店的拣货员信息
export const getPickUserList = (param, option) => {
  return request.get(api.userList, param, option)
}
